package com.sfzd5.UI;

import com.sfzd5.exam.helplibrary.taskstatisitcs.QuestionInfo;

import javax.swing.*;
import java.awt.*;
import java.text.NumberFormat;

public class QuestionInfoCellRenderer extends JPanel implements ListCellRenderer  {

    NumberFormat format;
    int studentCount;
    public QuestionInfoCellRenderer (int studentCount){
        this.studentCount = studentCount;
        format = NumberFormat.getPercentInstance();
        format.setMaximumFractionDigits(2);
    }
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        QuestionInfo questionInfo = (QuestionInfo) value;
        QuestionInfoPanel p = new QuestionInfoPanel(questionInfo, studentCount, format);
        return p.mPanel;
    }
}
